{#
 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at https://mozilla.org/MPL/2.0/.
#}

{%- set available_languages = get_locale_options(request, translations) -%}

{% if available_languages|length > 1 %}
  <form id="lang_form" class="mzp-c-language-switcher" method="get" action="#">
    <a class="mzp-c-language-switcher-link" href="{{ url('mozorg.locales') }}">{{ ftl('footer-language') }}</a>
    <label for="page-language-select">{{ ftl('footer-language') }}</label>
    <select id="page-language-select" class="mzp-js-language-switcher-select" name="lang" dir="ltr" data-testid="footer-language-select">
      {% for code, label in available_languages|dictsort -%}
        {# Don't escape the label as it may include entity references
        # like "Português (do&nbsp;Brasil)" (Bug 861149) #}
        <option lang="{{ code }}" value="{{ code }}"{{ code|ifeq(LANG, " selected") }}>{{ label|safe|replace('English (US)', 'English') }}</option>
      {% endfor %}
    </select>
    <button type="submit">{{ ftl('footer-go') }}</button>
  </form>
{% endif %}
